package Model;

import java.io.Serializable;
import java.util.ArrayList;

import Model.Player;
import Model.PropertySpace;

import Messaging.Notification;
import Messaging.NotificationManager;

/*
 * @author Roch San Buenaventura
 */

public class TaxSpace extends Space implements Serializable 
{
	private int fee_;
	private double percentageFee_;
	
	final static long serialVersionUID = 222;
	
	public TaxSpace() 
	{
		Name_ = "NONE";
		fee_ = 0;
		percentageFee_ = 0.0;
	}

	public TaxSpace(String name) 
	{
		Name_ = name;
		fee_ = 0;
		percentageFee_ = 0.0;
	}
	
	public TaxSpace(String name, int fee, double percentageFee)
	{
		Name_ = name;
		fee_ = fee;
		percentageFee_ = percentageFee;
	}
	
	public void landOn(Player p) {
		int assets = p.getCash();
		ArrayList<PropertySpace> properties = p.getProperties();
		for (int i = 0; i < properties.size(); ++i) {
			assets += properties.get(i).getMortgageValue();
		}
		
		int value = 0;
		String message = p.getName() + " paid $";
		
		if(Name_.equals("Income Tax")) {
			value = Math.min((int)(assets * .1), 200);
			message += value + " in Income Tax";
		}

		else {
			value = 75;
			message += value + " in Luxury Tax";
		}
		
		
		p.updateCash(-value);
		NotificationManager.getInstance().notifyObservers(Notification.UPDATE_CASH, 
				new Integer(value));
		NotificationManager.getInstance().notifyObservers(Notification.ACTION_MESSAGE, 
				message);
			
	}

	public void setFee(int fee) 
	{
		this.fee_ = fee;
	}

	public int getFee() 
	{
		return fee_;
	}

	public void setPercentageFee(double percentageFee) 
	{
		percentageFee_ = percentageFee;
	}

	public double getPercentageFee() 
	{
		return percentageFee_;
	}

}
